import { createSlice } from '@reduxjs/toolkit'
export interface CounterState {
    value: number;
    status: 'idle' | 'loading' | 'failed';
  }
const initialState: CounterState = {
    value: 0,
    status: 'idle',
}

export const counterSlice = createSlice({
  name: 'counter',
  initialState,
  reducers: {
    increment: (state) => {
      state.value += 1
    },
    decrement: (state) => {
      state.value -= 1
    },
    incrementByAmount: (state, action) => {
      state.value += action.payload
    },
  },
})

// Action creators are generated for each case reducer function
export const { increment, decrement, incrementByAmount } = counterSlice.actions

export default counterSlice.reducer
